.class public Lrexsee/core/transportation/RexseeAdvanceDownload;
.super Lrexsee/core/transportation/RexseeDownload;
.source "RexseeAdvanceDownload.java"

# interfaces
.implements Lrexsee/core/browser/clazz/JavascriptInterface;


# static fields
.field private static final INTERFACE_NAME:Ljava/lang/String; = "AdvanceDownload"


# direct methods
.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 0
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 25
    invoke-direct {p0, p1}, Lrexsee/core/transportation/RexseeDownload;-><init>(Lrexsee/core/browser/Browser;)V

    .line 26
    return-void
.end method


# virtual methods
.method public clearPrivateDownloads()V
    .locals 8

    .prologue
    .line 43
    :try_start_0
    iget-object v5, p0, Lrexsee/core/transportation/RexseeAdvanceDownload;->mContext:Landroid/content/Context;

    const-string v6, "download"

    const/4 v7, 0x0

    invoke-virtual {v5, v6, v7}, Landroid/content/Context;->getDir(Ljava/lang/String;I)Ljava/io/File;

    move-result-object v0

    .line 44
    .local v0, "dir":Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->list()[Ljava/lang/String;

    move-result-object v4

    .line 45
    .local v4, "list":[Ljava/lang/String;
    const/4 v3, 0x0

    .local v3, "i":I
    :goto_0
    array-length v5, v4

    if-lt v3, v5, :cond_0

    .line 52
    .end local v0    # "dir":Ljava/io/File;
    .end local v3    # "i":I
    .end local v4    # "list":[Ljava/lang/String;
    :goto_1
    return-void

    .line 46
    .restart local v0    # "dir":Ljava/io/File;
    .restart local v3    # "i":I
    .restart local v4    # "list":[Ljava/lang/String;
    :cond_0
    new-instance v2, Ljava/io/File;

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-virtual {v0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v6

    invoke-static {v6}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v6

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v6, "/"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    aget-object v6, v4, v3

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-direct {v2, v5}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 47
    .local v2, "file":Ljava/io/File;
    invoke-virtual {v2}, Ljava/io/File;->delete()Z
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 45
    add-int/lit8 v3, v3, 0x1

    goto :goto_0

    .line 49
    .end local v0    # "dir":Ljava/io/File;
    .end local v2    # "file":Ljava/io/File;
    .end local v3    # "i":I
    .end local v4    # "list":[Ljava/lang/String;
    :catch_0
    move-exception v5

    move-object v1, v5

    .line 50
    .local v1, "e":Ljava/lang/Exception;
    iget-object v5, p0, Lrexsee/core/transportation/RexseeAdvanceDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeAdvanceDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6, v1}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/Exception;)V

    goto :goto_1
.end method

.method public getInheritInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 1
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 21
    new-instance v0, Lrexsee/core/transportation/RexseeAdvanceDownload;

    invoke-direct {v0, p1}, Lrexsee/core/transportation/RexseeAdvanceDownload;-><init>(Lrexsee/core/browser/Browser;)V

    return-object v0
.end method

.method public getInterfaceName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 17
    new-instance v0, Ljava/lang/StringBuilder;

    iget-object v1, p0, Lrexsee/core/transportation/RexseeAdvanceDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v1, v1, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v1, v1, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "AdvanceDownload"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getPrivateDownloadPath(Ljava/lang/String;)Ljava/lang/String;
    .locals 8
    .param p1, "url"    # Ljava/lang/String;

    .prologue
    const/4 v6, 0x0

    const-string v7, ":Error on extracting the file name from the url."

    const-string v5, "/"

    .line 29
    const-string v1, "/"

    invoke-virtual {p1, v5}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_0

    .line 30
    iget-object v1, p0, Lrexsee/core/transportation/RexseeAdvanceDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeAdvanceDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v2

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v4, ":Error on extracting the file name from the url."

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v1, v2, v3}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move-object v1, v6

    .line 38
    :goto_0
    return-object v1

    .line 33
    :cond_0
    const-string v1, "/"

    invoke-virtual {p1, v5}, Ljava/lang/String;->lastIndexOf(Ljava/lang/String;)I

    move-result v1

    add-int/lit8 v1, v1, 0x1

    invoke-virtual {p1, v1}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v0

    .line 34
    .local v0, "fileName":Ljava/lang/String;
    if-eqz v0, :cond_1

    const-string v1, ""

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_2

    .line 35
    :cond_1
    iget-object v1, p0, Lrexsee/core/transportation/RexseeAdvanceDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeAdvanceDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v2

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v4, ":Error on extracting the file name from the url."

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v1, v2, v3}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move-object v1, v6

    .line 36
    goto :goto_0

    .line 38
    :cond_2
    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "file://"

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v2, p0, Lrexsee/core/transportation/RexseeAdvanceDownload;->mContext:Landroid/content/Context;

    const-string v3, "download"

    const/4 v4, 0x0

    invoke-virtual {v2, v3, v4}, Landroid/content/Context;->getDir(Ljava/lang/String;I)Ljava/io/File;

    move-result-object v2

    invoke-virtual {v2}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, "/"

    invoke-virtual {v1, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    goto :goto_0
.end method

.method public getPrivateDownloads()Ljava/lang/String;
    .locals 9

    .prologue
    const-string v6, "\""

    .line 55
    :try_start_0
    iget-object v6, p0, Lrexsee/core/transportation/RexseeAdvanceDownload;->mContext:Landroid/content/Context;

    const-string v7, "download"

    const/4 v8, 0x0

    invoke-virtual {v6, v7, v8}, Landroid/content/Context;->getDir(Ljava/lang/String;I)Ljava/io/File;

    move-result-object v0

    .line 56
    .local v0, "dir":Ljava/io/File;
    const-string v5, ""

    .line 57
    .local v5, "rtn":Ljava/lang/String;
    invoke-virtual {v0}, Ljava/io/File;->list()[Ljava/lang/String;

    move-result-object v4

    .line 58
    .local v4, "list":[Ljava/lang/String;
    const/4 v3, 0x0

    .local v3, "i":I
    :goto_0
    array-length v6, v4

    if-lt v3, v6, :cond_0

    .line 62
    new-instance v6, Ljava/lang/StringBuilder;

    const-string v7, "["

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v6, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    const-string v7, "]"

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    .line 65
    .end local v0    # "dir":Ljava/io/File;
    .end local v3    # "i":I
    .end local v4    # "list":[Ljava/lang/String;
    .end local v5    # "rtn":Ljava/lang/String;
    :goto_1
    return-object v6

    .line 59
    .restart local v0    # "dir":Ljava/io/File;
    .restart local v3    # "i":I
    .restart local v4    # "list":[Ljava/lang/String;
    .restart local v5    # "rtn":Ljava/lang/String;
    :cond_0
    new-instance v6, Ljava/lang/StringBuilder;

    const-string v7, "file://"

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    const-string v7, "/"

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    aget-object v7, v4, v3

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 60
    .local v2, "f":Ljava/lang/String;
    new-instance v6, Ljava/lang/StringBuilder;

    invoke-static {v5}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    if-nez v3, :cond_1

    new-instance v7, Ljava/lang/StringBuilder;

    const-string v8, "\""

    invoke-direct {v7, v8}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v7, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    const-string v8, "\""

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    :goto_2
    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    .line 58
    add-int/lit8 v3, v3, 0x1

    goto :goto_0

    .line 60
    :cond_1
    new-instance v7, Ljava/lang/StringBuilder;

    const-string v8, ",\""

    invoke-direct {v7, v8}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v7, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    const-string v8, "\""

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v7

    goto :goto_2

    .line 63
    .end local v0    # "dir":Ljava/io/File;
    .end local v2    # "f":Ljava/lang/String;
    .end local v3    # "i":I
    .end local v4    # "list":[Ljava/lang/String;
    .end local v5    # "rtn":Ljava/lang/String;
    :catch_0
    move-exception v6

    move-object v1, v6

    .line 64
    .local v1, "e":Ljava/lang/Exception;
    iget-object v6, p0, Lrexsee/core/transportation/RexseeAdvanceDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeAdvanceDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7, v1}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/Exception;)V

    .line 65
    const-string v6, "[]"

    goto :goto_1
.end method

.method public privateDownload(Ljava/lang/String;)V
    .locals 1
    .param p1, "url"    # Ljava/lang/String;

    .prologue
    .line 69
    const/4 v0, 0x1

    invoke-virtual {p0, p1, v0}, Lrexsee/core/transportation/RexseeAdvanceDownload;->privateDownload(Ljava/lang/String;Z)V

    .line 70
    return-void
.end method

.method public privateDownload(Ljava/lang/String;Z)V
    .locals 2
    .param p1, "url"    # Ljava/lang/String;
    .param p2, "cancelable"    # Z

    .prologue
    .line 72
    new-instance v0, Lrexsee/core/transportation/DownloadFile;

    invoke-direct {v0}, Lrexsee/core/transportation/DownloadFile;-><init>()V

    .line 73
    .local v0, "downloadFile":Lrexsee/core/transportation/DownloadFile;
    iget-object v1, p0, Lrexsee/core/transportation/RexseeAdvanceDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->urlListeners:Lrexsee/core/browser/RexseeUrl;

    invoke-virtual {v1, p1}, Lrexsee/core/browser/RexseeUrl;->getAbsoluteUrl(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, v0, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    .line 74
    iget-object v1, v0, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    invoke-virtual {p0, v1}, Lrexsee/core/transportation/RexseeAdvanceDownload;->getPrivateDownloadPath(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, v0, Lrexsee/core/transportation/DownloadFile;->path:Ljava/lang/String;

    .line 75
    new-instance v1, Lrexsee/core/transportation/RexseeAdvanceDownload$1;

    invoke-direct {v1, p0, p2}, Lrexsee/core/transportation/RexseeAdvanceDownload$1;-><init>(Lrexsee/core/transportation/RexseeAdvanceDownload;Z)V

    invoke-virtual {p0, v0, v1}, Lrexsee/core/transportation/RexseeAdvanceDownload;->download(Lrexsee/core/transportation/DownloadFile;Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;)V

    .line 101
    return-void
.end method

.method public privateDownloadWithCallback(Ljava/lang/String;)V
    .locals 2
    .param p1, "url"    # Ljava/lang/String;

    .prologue
    .line 103
    new-instance v0, Lrexsee/core/transportation/DownloadFile;

    invoke-direct {v0}, Lrexsee/core/transportation/DownloadFile;-><init>()V

    .line 104
    .local v0, "downloadFile":Lrexsee/core/transportation/DownloadFile;
    iget-object v1, p0, Lrexsee/core/transportation/RexseeAdvanceDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->urlListeners:Lrexsee/core/browser/RexseeUrl;

    invoke-virtual {v1, p1}, Lrexsee/core/browser/RexseeUrl;->getAbsoluteUrl(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, v0, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    .line 105
    iget-object v1, v0, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    invoke-virtual {p0, v1}, Lrexsee/core/transportation/RexseeAdvanceDownload;->getPrivateDownloadPath(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, v0, Lrexsee/core/transportation/DownloadFile;->path:Ljava/lang/String;

    .line 106
    new-instance v1, Lrexsee/core/transportation/RexseeAdvanceDownload$2;

    invoke-direct {v1, p0}, Lrexsee/core/transportation/RexseeAdvanceDownload$2;-><init>(Lrexsee/core/transportation/RexseeAdvanceDownload;)V

    invoke-virtual {p0, v0, v1}, Lrexsee/core/transportation/RexseeAdvanceDownload;->download(Lrexsee/core/transportation/DownloadFile;Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;)V

    .line 112
    return-void
.end method
